<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div>div</div>
    <p>p</p> 
    <div>div</div>
    <span>span</span>
    <p>p</p> 
    <div>div</div>
</body>
<script>
    function select( selector ) {
        return document.querySelectorAll( selector ); // 伪数组
    }
    function each( arr, callback ) {
         for ( var i = 0; i < arr.length; i++ ) { 
            callback( arr[ i ], i );
         }
    }


    // 
    var nodes = select( 'div, p' );
    each( nodes, function ( v ) {
        v.style.border = v.nodeName == 'DIV'  
                         ? '1px solid red'
                         : '1px solid blue';
    });


    // $( 'div, p' ).css( ... )

    // function func() {
    //     return {
    //         each: function () {}
    //     }
    // }

    // func().each();


</script>
</html>